package com.huzz.service.impl;

import cloud.tianai.captcha.spring.application.ImageCaptchaApplication;
import cloud.tianai.captcha.spring.vo.CaptchaResponse;
import cloud.tianai.captcha.spring.vo.ImageCaptchaVO;
import cloud.tianai.captcha.validator.common.model.dto.ImageCaptchaTrack;
import com.huzz.service.CaptchaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Name 名称
 * @Description 描述
 * @Author 童年的纸飞机
 * @Since 2023-06-2023/6/7 16:21
 */
@Service
public class CaptchaServiceImpl implements CaptchaService {

    @Autowired
    private ImageCaptchaApplication imageCaptchaApplication;

    @Override
    public CaptchaResponse<ImageCaptchaVO> generateCaptcha(String captchaType) {
        return imageCaptchaApplication.generateCaptcha(captchaType);
    }

//    @Override
//    public boolean verifyCaptcha(CaptchaRequest<Map> captchaRequest) {
//        return imageCaptchaApplication.matching(captchaRequest.getId(), captchaRequest.getCaptchaTrack());
//    }

    @Override
    public boolean verifyCaptcha(String id, ImageCaptchaTrack imageCaptchaTrack) {
        return imageCaptchaApplication.matching(id, imageCaptchaTrack);
    }
}
